<template>
	<view class="index" style="padding: 20rpx 0 0;">
		<block v-if="BrowseList.length">
			<view class="index-item index-item-5" style="margin: 0 0 20rpx; border-radius: 0; padding-top: 0;">
				<view class="index-item-5-list">
					<view class="index-item-5-item" v-for="(data,index) in BrowseList" :key="index" @click="goInfo(data.user_id,1)">
						<view class="index-item-5-item-top">
							<image :src="data.heard_img"></image>
							<view class="index-item-5-item-top-left">
								<view class="top">{{data.nickname}} <text class="time">{{data.add_time}}</text></view>
								<view class="bottom">
									ID:{{data.user_id}} 
									<text>
										<text v-if="data.type==1">小程序</text>
										<text v-if="data.type==2">APP</text>
										<text v-if="data.type==3">H5</text>
										<text v-if="data.type==4">PC</text>
										<text v-if="data.type==5">Ipad</text>
										<text v-if="data.type==6">后台系统</text>
									</text>
								</view>
							</view>
						</view>
						<view class="index-item-5-item-bottom footprint-goods">
							<image :src="data.image_middle"></image>
							<view class="index-item-5-item-bottom-info">
								<view class="title">{{data.goods_name}}</view>
								<view class="price">￥<text>{{data.retail_price}}</text></view>
								<view class="times">浏览次数:{{data.num}}次</view>
								<button plain type="primary" size="mini">查看详情</button>
							</view>
						</view>
					</view>
				</view>
			</view>
			<no-more :text="'数据加载完毕'" v-if="BrowseList.length && noMore"></no-more>
		</block>
		<block v-else>
			<nothing :text="'暂无数据'" :btn="false"></nothing>
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 0,
				noMore: false,
				BrowseList: []
			};
		},
		onLoad() {
			this.getBrowseList()
		},
		onReachBottom() {
			if(!this.noMore){
				this.page++
				this.getBrowseList(this.page)
			}
		},
		methods: {
			// 获取用户足迹
			getBrowseList(page){
				this.$api.BrowseItems({page: page?page:0, limit: 10, store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id,group: 1,paramter: 1,is_new: 1}).then(res => {
					if(res.datas.list.length){
						res.datas.list.forEach(item => {
							this.BrowseList.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
			// 跳转用户足迹详情
			goInfo(user_id,type){
				uni.navigateTo({
					url: '/pages/index/user-dynamic-info?user_id='+user_id+'&type='+type
				})
			}
		}
	}
</script>

<style lang="scss">
	@import '../../static/scss/index.scss';
</style>
